﻿using System.Reflection;
using TaiwuModFramework.Common.Base;

namespace TaiwuModFramework.Common.Abstract {
    public abstract class AService {

        // 日志工具
        private ALogger log;
        public ALogger Log {
            get {
                return log != null ? log : AFwDomain.Log;
            }

            protected internal set {
                log = value;
            }
        }


        public void SetLogger(ALogger log) {
            if(log == null) return;
            Log = log;
            FieldInfo logField = GetType().GetField("Log", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Public | BindingFlags.Instance);
            if(logField != null) {
                logField.SetValue(this, log);
            }
        }
        public ALogger GetLogger() {
            return Log;
        }
    }
}
